#include "CWinTest.h"

void CWinTest::OnFinalMessage(HWND hWnd)
{
    if (hBrush)
        ::DeleteObject(hBrush);
}

LRESULT CWinTest::OnDestroyHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    PostQuitMessage(0);
    return 0;
}

LRESULT CWinTest::OnCreateHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    RECT rc = { 0,0,100,20 };
    m_Static.Create(L"Static", m_hWnd, rc, L"static", WS_CHILD | WS_VISIBLE);
    hBrush = CreateSolidBrush(COLORREF(RGB(255, 0, 0)));
    CenterWindow();
    return 0;
}

LRESULT CWinTest::OnColorHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    HDC hDC = (HDC)wParam;
    HWND hWnd = (HWND)lParam;

    if (hWnd == m_Static.m_hWnd)
    {
        SetTextColor(hDC, COLORREF(RGB(0, 0, 255)));
        SetBkColor(hDC, COLORREF(RGB(255, 0, 0)));
    }
    return (LRESULT)hBrush;
}
